package com.basic.reptile;

import java.io.UnsupportedEncodingException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.basic.http.HttpUtils;

/**
 * 33IQ测评问答网站数据爬取
 * @author Administrator
 *
 */
public class IqTest {
	
	public static void main(String[] args) throws UnsupportedEncodingException {
		//String source = HttpUtils.cs("GBK").get("https://www.33iq.com/quiz/xinli.html");
		String source = HttpUtils.cs("GBK").get("https://www.33iq.com/quiz/quizload?q_id=581&question=1&subquestion=8818");
		String result = new String(source.getBytes(), "UTF-8");
		System.out.println(result);
//		for (int i = 1; i <= 4; i++) {
//			String beginIndexPoint = i+".";
//			String first = result.substring(result.indexOf(beginIndexPoint));
//			System.out.println(replaceBlank(first.substring(0, first.indexOf("</div>"))));
//		}
	}

	public static String replaceBlank(String str) {
		String dest = "";
		if (str!=null) {
			Pattern p = Pattern.compile("\\s*|\t|\r|\n");
			Matcher m = p.matcher(str);
			dest = m.replaceAll("");
		}
		return dest;
	}
	
}
